package com.itany.thread.test01;

public class ThreadB implements Runnable{
	private Object obj1;
	private Object obj2;
	public ThreadB(Object obj1,Object obj2) {
		this.obj1 = obj1;
		this.obj2 = obj2;
	}	
	@Override
	public void run() {
		synchronized (obj2) {
			System.out.println("ThreadB get obj2 wait obj1");
			try {
				Thread.sleep(2000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			synchronized (obj1) {
				System.out.println("ThreadB get obj1");
			}
		}
	}
	
}
